//
//  ViewController.m
//  02-UIViewController
//
//  Created by LL.F on 16/7/15.
//  Copyright © 2016年 LL.F. All rights reserved.
//

#import "ViewController.h"
#import "PresentViewController.h"

@interface ViewController ()
@property (nonatomic, strong) UIView *subView;
@end


@implementation ViewController
#pragma mark --注意: 进程一. 二. 三只走一次
// 进程一: 初始化方法(不要在这个方法中去加载视图, 而应该去初始化一些数据相关的内容)
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
 NSLog(@"初始化");
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    
    }
    return self;
}
// 进程二. loadView
// 加载view 加载UIViewController中的view
// UINavigationController UITableViewController 在loadView中是对self.view的重写
- (void)loadView
{
     [super loadView];
    NSLog(@"loadView");
    // 在这里要做的是, 改变self.view
    self.view.backgroundColor = [UIColor redColor];
     NSLog(@"试图加载");
    
    
}
// 进程三. viewDidLoad
// view已经加载
// 在这里写所有自定义视图的创建
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"viewDidLoad");
    NSLog(@"加载完成");
//    self.view = nil;
//    NSLog(@"%@", self.view);

  

}
// 开始触摸方法
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
     // 模态
    PresentViewController *present = [[PresentViewController alloc] init];
    // 模态动画效果
    present.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    // UIModalTransitionStyleCoverVertical 默认效果, 枚举为0
    // UIModalTransitionStyleFlipHorizontal 左右旋转翻页
    // UIModalTransitionStyleCrossDissolve 渐变效果
    // UIModalTransitionStylePartialCurl 翻书效果
    [self presentViewController:present animated:YES completion:^{
//        NSLog(@"模态完成");
    }];
 NSLog(@"开始触摸");

    
}
#pragma mark --注意: 下述四个方法会执行多次
// 视图将要出现时
- (void)viewWillAppear:(BOOL)animated
{
 NSLog(@"将要出现");
    [super viewWillAppear:animated];
}
// 视图已经出现时
- (void)viewDidAppear:(BOOL)animated
{
 NSLog(@"已经出现");
    [super viewDidAppear:animated];
}
// 视图将要消失时
- (void)viewWillDisappear:(BOOL)animated
{
 NSLog(@"将要消失");
    [super viewWillDisappear:animated];
    
}
// 视图已经消失时
- (void)viewDidDisappear:(BOOL)animated
{
     NSLog(@"已经消失");
    [super viewDidDisappear:animated];

}

// 接收到内存警告时执行的方法
- (void)didReceiveMemoryWarning {
    // 从父类继承来的方法中有内存警告的打印
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    // 释放部分内存资源
    // 把未显示在屏幕上的资源置空
    
}
// getter方法: 懒加载形式
- (UIView *)subView
{
    if (_subView == nil) {
        _subView = [UIView new];
        [self loadView];
    }
    return _subView;
}
@end
